package com.qdh.demotest;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class Subjectnew implements Writable {
    private int chinese;
    private int math;
    private int english;
    private int sum;

    public Subjectnew(int chinese, int english, int math, int sum) {
        this.chinese = chinese;
        this.english = english;
        this.math = math;
        this.sum = sum;
    }

    public Subjectnew() {
    }

    public int getChinese() {
        return chinese;
    }

    public void setChinese(int chinese) {
        this.chinese = chinese;
    }

    public int getMath() {
        return math;
    }

    public void setMath(int math) {
        this.math = math;
    }

    public int getEnglish() {
        return english;
    }

    public void setEnglish(int english) {
        this.english = english;
    }

    public int getSum() {
        return sum;
    }

    public void setSum(int sum) {
        this.sum = sum;
    }

    @Override
    public String toString() {
        return " 语文成绩 " + chinese +
                " 数学成绩 " + math +
                " 英语成绩 " + english +
                " 总成绩 " + sum ;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeInt(chinese);
        dataOutput.writeInt(english);
        dataOutput.writeInt(math);
        dataOutput.writeInt(sum);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.chinese = dataInput.readInt();
        this.math = dataInput.readInt();
        this.english = dataInput.readInt();
        this.sum = dataInput.readInt();
    }
}
